package helper;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class JAXBObjectWriter {
	
	public static<T> void writeString(T object,String filepath,String schemaLocation){
	
		try {  
			File file = new File(filepath);  
			JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass());  
			Marshaller jaxbMarshaller = jaxbContext.createMarshaller();  
			jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
			jaxbMarshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation); 
			jaxbMarshaller.marshal(object, file);  
		} catch (JAXBException e) {  
			e.printStackTrace();  
		}  
	}
}
